home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
newsgroups
/
misc.19970929-19971216
/
000191_news@newsmaster….columbia.edu _Tue Oct 28 09:42:32 1997.msg
< prev
next >
Wrap
Internet Message Format
|
1997-12-15
|
4KB
Return-Path: <news@newsmaster.cc.columbia.edu>
Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.35.30])
by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id JAA11713
for <kermit.misc@watsun.cc.columbia.edu>; Tue, 28 Oct 1997 09:42:31 -0500 (EST)
Received: (from news@localhost)
by newsmaster.cc.columbia.edu (8.8.5/8.8.5) id JAA03830
for kermit.misc@watsun; Tue, 28 Oct 1997 09:42:31 -0500 (EST)
Path: news.columbia.edu!watsun.cc.columbia.edu!fdc
From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
Newsgroups: comp.protocols.kermit.misc
Subject: Re: Reading filename one at a time.
Date: 28 Oct 1997 14:42:28 GMT
Organization: Columbia University
Lines: 82
Message-ID: <634tkk$d8v$1@apakabar.cc.columbia.edu>
References: <631sbo$hnl$1@goanna.cs.rmit.edu.au>
NNTP-Posting-Host: watsun.cc.columbia.edu
Xref: news.columbia.edu comp.protocols.kermit.misc:7972
In article <631sbo$hnl$1@goanna.cs.rmit.edu.au>,
Ross Irvine <rwi@yallara.cs.rmit.edu.au> wrote:
: I have more Kermit questions. :)
: I'd like to do this.
:
: while (no more files in dirctory)
: read filename into variable %a
: send %a
: if success delete %a
: end loop
:
That's easy, it's a no-op :-) Maybe you meant:
: while (more files in directory)
: read filename into variable %a
: send %a
: if success delete %a
: end loop
By the way, there is a MOVE command that does this (sends one or more files,
and then deletes the source if and only if the transfer was successful).
: Basically I'd like to read all the filenames in a directory one at a time
: so I can work with each file seperately. This is using K95, but will
: hopefully work in msdos. I've looked through the Kermit book but haven't
: been able to find anything.
:
Look on page 398. Here's a more complete example; modify as desired.
It assumes there is a Kermit server of recent vintage on the far end:
---(cut)---
local \%i \%f \%m \%n
cd desired-directory
assign \%n \ffiles(*) ; The number of files in this directory.
declare \&a[\%n] ; Create an array to hold their names.
for \%i 1 \%n 1 { ; Fill the array
assign \&a[\%i] \fnextfile()
}
define \%m 0 ; Counter for successful transfers
set file type binary ; Transfer in binary mode
for \%i 1 \%n 1 { ; Loop to do each file
assign \%s \fsize(\&a[\%i]) ; Size of local file we are sending
send \&a[\%i] ; Try to send it
if fail continue ; If we failed just go on to next one
remote query kermit files(\&a[\%i])
if equal "\v(query)" "" continue
if not equal "\v(query)" "1" continue
xif equal "\v(program)" "C-Kermit" {
remote query kermit crc16
if equal {\v(query)} {} continue
if not equal {\v(query)} {\v(crc)} continue
remote query kermit fsize
if equal {\v(query)} {} continue
if not equal {\v(query)} {\%s} continue
}
delete \&a[\%i]
increment \%m ; And count it.
}
echo DONE
echo \%m FILE(S) TRANSFERRED.
echo \feval(\%n-\%m) FILE(S) NOT TRANSFERRED.
---(cut)---
Notes: This script is ultra-paranoid about the success of the transfer.
Really, you could replace the entire script with "move *" and have the
same effect. But this approach lets you add any other stuff you might like
to do on a per-file basis.
The script illustrates how to do extra checking after the transfer: does the
file really exist on the far side? (Of course it does, or else the SEND would
not have succeeded). Is its size the same as the source file? Do the CRC's
match? If and only if it passes all those tests, it is deleted. C-Kermit
6.0, K95 1.1.13, or MS-DOS Kermit 3.15 or later are required.
The 'xif equal "\v(program)" "C-Kermit"' section takes advantage of features
that are in C-Kermit 6.0 and K95 but not in MS-DOS Kermit 3.15. You can use
this same construction to deal with any other differences.
- Frank